package contacts.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import contacts.dao.IContactsDao;
import contacts.db.DbConnection;
import contacts.po.Room;
import contacts.po.Student;

public class JTableDaoImpl implements IContactsDao {

	/**
	 * 逐一获取一个学生对象中的全部信息
	 */
	@Override
	public String getMessage(Student student, int i) {
		RoomDaoImpl roomDao = null;
		Connection conn = null;
		ResultSet rs = null;
		PreparedStatement ps = null;
		conn = DbConnection.getConnection();
		String message = null;
		String sql = "select * from student where student_id = ?";
		try {
			ps = conn.prepareStatement(sql);
			ps.setString(1, student.getStudentId());
			rs = ps.executeQuery();
			while (rs.next()) {
				roomDao = new RoomDaoImpl();
				if (i == 3) {
					message = roomDao.getRoomNo(student.getRoom());
				} else {
					message = rs.getString(i);
				}
			}
		} catch (SQLException e) {
		} finally {
			DbConnection.close(ps, null);
		}
		return message;
	}

	@Override
	public void save(Student student) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(Student student) {
		// TODO Auto-generated method stub

	}

	@Override
	public Student get(String studentId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void delete(String studentId) {
		// TODO Auto-generated method stub

	}

	@Override
	public String getRoomNo(Room room) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Student> findAll() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int getRoomId(Room room) {
		// TODO Auto-generated method stub
		return 0;
	}

}
